
<form class="layui-form model-form" id="auth-client-secret-form">
    <input type="hidden" name="id" >
    <div class="layui-form-item">
        <label class="layui-form-label">原始密码:</label>
        <div class="layui-input-block">
            <input type="password" name="oldPsw" placeholder="请输入原始密码" class="layui-input"
                   lay-verType="tips" lay-verify="required" required/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">新密码:</label>
        <div class="layui-input-block">
            <input type="password" name="newPsw" placeholder="请输入新密码" class="layui-input"
                   lay-verType="tips" lay-verify="required|psw" required/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">确认密码:</label>
        <div class="layui-input-block">
            <input type="password" name="rePsw" placeholder="请再次输入新密码" class="layui-input"
                   lay-verType="tips" lay-verify="required|repsw" required/>
        </div>
    </div>
    <div  style="display: none">
        <button class="layui-btn" lay-filter="auth-client-secret-submit" id = "auth-client-secret-submit" lay-submit>保存</button>
    </div>
</form>
<script>
    layui.use(['layer', 'form', 'admin'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var admin = layui.admin;
       var id = admin.getTempData('auth-client-resetSecret');
$("#auth-client-secret-form [name='id']").val(id);
        // 监听提交
        form.on('submit(auth-client-secret-submit)', function (data) {
            admin.req("auth/client/modifyPass",data.field,function(res){
                layer.msg("修改密码成功",{icon:1})
                layer.close(layer.curr_idex);
            },"post")
            return false;
        });

        // 添加表单验证方法
        form.verify({
            psw: [/^[\S]{5,12}$/, '密码必须5到12位，且不能出现空格'],
            repsw: function (t) {
                if (t !== $('#auth-client-secret-form input[name=newPsw]').val()) {
                    return '两次密码输入不一致';
                }
            }
        });

    });
</script>
</body>
</html>